<?php

class komentar{

        var $host;
        var $user;
        var $pass;
        var $dbnm;
        var $db;
        
        function __construct($host,$user,$pass,$dbnm){
			    $this->host = $host;
                $this->user = $user;
                $this->pass = $pass;
                $this->dbnm = $dbnm;
        }
        
        function _connect(){
                $this->db = mysql_connect($this->host,$this->user,$this->pass);
                mysql_select_db($this->dbnm,$this->db);
        }
        
                function get_data(){
                        
                        $this->_connect();
                        $sql = 'SELECT * FROM komentar ';
                        $result = mysql_query($sql);
                        return $result;
                }
                
                function komentar($data){
                
                        $this->_connect();
                        $sql = '
                                INSERT 
                                INTO
                                komentar
                                (
                                        email,
                                        nama,
                                        komentar
                                        
										                                )
                                VALUES
                                (
                                        "'.$data['emaill'].'",
                                        "'.$data['namaa'].'",
                                        "'.$data['komentarr'].'"
                                        
										                          )
                        ';
					
                        $result = mysql_query($sql);
						if($result){	
							header('location:kontak.php?message=success');
						}
						else {
							header('location:kontak.php?message=warning');
						}

                }
}